Is it possible to buy a retired Boeing 747 aircraft?
Sure, the 747 is a Type Certified and airworthy aircraft, the FAA does not really care who owns it so long as they play by the rules. Boeing even sells them directly to the private market via their BBJ line. 

There are even a few used ones listed for sale right now.

Some people even buy them for other purposes than flying them...


  for how long will boeing keep maintaining its aircraft in light of
  manufacturing spare parts and innovating it


this is impossible to speculate on as its their decision ultimately but considering how many 747's there are you will be flying it long into the future.