"At the beginning" has to do with the time that something starts (you use this when writing a tale or a story). "In the beginning" is used to talk about a situation:
For example...
At the beginning of the Machpichu`s Dynasty, Inca people would try agriculture methods as a way of making a living.
At the beginning of Spring flowers have a tendency to open their petals.
-
In the beginning I realised that he wasn`t the right type (= On first acquaintance I noticed he wasn`t the right type)
In the beginning, he was taken aback, but then relaxed as the accident wasn`t serious.