It seems there are really 2 questions here:
私は妹に新しいおもちゃを買いました。
is completely standard. に binds to a noun and marks is as indirect object, i.e. you bought the toy to or for the/your little sister.
In the other sentence, something else is going on:
よい子になるには早寝早起するコトです。
In order to become a good child, you have to get up early and go to sleep early.
The easiest way is to read this as a fixed construction ~には~ used for expressing "In order to something, you have to something / something has to happen". Note that you can't use には to mean "in order to" generally, the "have to" part needs to be there, e.g.
*よい子になるに(は)早寝早起した
He got up early and went to sleep early in order to become a good child
is ungrammatical. It would have to be e.g. よい子になるために早寝早起した
A bit of background is that Japanese used to have zero-nominalization, i.e. you were able to attach case particles to verbs as is they were nouns. In modern Japanese, this is not generally felicitous, but survives in many fixed constructions.
" なるに× なるには○ よい子になるには / 早寝早起きすることです。 To be a good boy / you go to bed early and wake up early.
宇宙飛行士になるには / たくさん勉強しなければならない。 To be an astronaut / you have to study hard.
駅に行くには / ここを通ればいい To get to the station, go this way."
That seems contrary to what you are saying (though I still think what you are saying is right) can you clarify?
– Nathan Oct 09 '13 at 02:54