Lego Mindstorms NXT is a great kit that allow you to build and program an almost unlimited variety of robots and automatisms.
The kit includes a “brick” that includes a programmable 32 bits microcontroller. Lego open sourced the software and the hardware of NXT, here you can find all the documents and source code.
You can program its microcontroller with the included visual programming tool, called NXT-G, that is very easy to use for small programs but probably you will find it too much limited, specially if you can program in other programming language. But don’t worry, you can use standard and professional programming languages like Java, C or C++ among others. All them free as in beer and as in speech.
Just a few words about which, in my opinion, are the best options:
Apart from NXT-G the easiest way for programming NXT is NXC. It’s a language similar to C, very easy to learn and you don’t should change the NXT Lego firmware, so you can continue using NXT-G.
If you know or want to learn Java this is your tool. I think that is the best tool, more difficult that NXC but far more powerful.
Do you want to learn C or C++? Real time programming? This is your tool!