What is the current estimation for how much time the Sun will function properly? Eventually, the Sun will run out of fuel, go dark, and other bad things will happen. About how much long is it predicted that we will have a sun functioning as it is currently?
Just to add to Undo's answer, after the expansion to a red giant, the sun will become a planetary nebula, where (according to the link) the fusion reactions inside the star are 'overtaken' by the gravitational collapse, in turn causing the inner layers to condense and heat up causing the outer layers to be blown away.  After which, the hot core forms the remnant, a White Dwarf star (NASA source), which is likely to last for several more billions of years.

The image below depicts the current ideas of the expected lifecycle and timeline of the life of the sun:



Image source

How do we know what will happen to the sun?

Currently, the main method to determine the solar lifecycle is described by the article "The Future of the Sun" (Cowing, 2013) is to:


  Studying stars with the same mass and composition as the Sun, the so-called "solar twins," can give us more information about our own Sun; solar twins of various ages offer snapshots of the Sun's evolution at different phases 


Where the mass and chemical composition of a star provide the information needed to determine its lifecycle.