A non terminating infinite loop is usually considered an error.
However there are some applications which are infinite loops on purpose. The are usually servers for event driven applications. Consider web servers. They loop infinitely until a request comes to them. They process the request and go back to their loop waiting for the next request.
Infinite loops can be nasty, so early computer theorist wondered if there was a way to detect them. In fact certain problems could be solved if we could tell if a program went into an infinite loop or not.
Alan Turing, one of the founders of computer science, provide the "halting problem." It answered the question, and he proved that one couldn't write a program which could determine if a general program contained an infinite loop or not.
The proof (by contradiction) goes along these lines.
Assume program, P, exists, and it reads another program, p, and tests it for infinite loops. It exhibits the following behavior:
P(p) prints "Halts" if p halts.
P(p) prints "Does not halt" if p does not halt.
Pretty straight forward assumption... ok?
Now, let's modify P to make a new program P', that does almost the same things as P, but just slightly different.
P'(p) goes into an infinite loop itself if p halts.
P'(p) halts if p goes into an infinite loop.
Basically, P' does the opposite of p.
Since P' works on any program, let's run the following:
P'(P') - basically have P' test itself. What does it do?
If P' halts, then P' doesn't halt.
If P' doesn't halt, then P' halts.
It can't do something and not do that thing at the same time. It's a contradiction, which unravels back to the assumption that P can exist.
Therefore P cannot exist.