Generally speaking, "in" means that something is surrounded by something. The thing forms an enclosure around the thing on all or most sides.
"On" means that a thing is touching the outside of the other thing. It doesn't completely surround it, but is in contact with and potentially even supporting it.
As for your examples:
American society is in trouble because the trouble is enclosing society in time. It's not trouble just at this very instant, or just in the past, or just in the future. It's a week (or a month, or a year, or a minute, or whatever) ago, now, and a week hence. It's surrounding and enclosing current society.
You talk about a word or phrase being in a sentence because the sentence contains it. In this sentence, the word "word" is after the start of the sentence but before the end. In the previous sentence, even the word "end" was in the sentence, as it was before the period.
These words are on your computer screen, as they are on the screen's surface. One one side of the words is the screen, on the other is the air.
There was a recent question about the difference between 'in' and 'on' when it comes to beds. The conclusion there was that being outside of the covers makes you on the bed. You're on its surface. If you're actually under the covers, then you are in the bed. You're surrounded on most sides by parts of the bed.
English is Hard
Obviously there are exceptions, and some situations could be interpreted either way depending on how you look at them. This means that, much of the time, you will simply need to know a set phrase and which preposition is normally used.