Both "寝る" and "眠る" are related to the concept of sleep in Japanese, but they are used in slightly different contexts:
寝る
Refers to the action of going to bed, lying down to sleep, or sleeping in a general sense.
Can be used for both intentional and unintentional sleep.
今夜早く寝ます
I will go to bed early tonight.
眠る
Specifically means to sleep or to be asleep.
Often used to describe the state of being in a deep or restful sleep.
彼は深く眠っている
He is sleeping deeply.
In summary, "寝る" is a more general term encompassing the act of sleeping, going to bed, or lying down, while "眠る" specifically refers to the state of being asleep.