So in this case let's first count our outs.
We have 8 cards that can make us our open ended straight draw, we also have another 7 cards that will make us our flush. So a total of 15. We know of our two cards plus the 3 flop cards, so we know there are 47 cards left in the deck.
So how do we work out the odds here? So we have 15 cards that make us win left in the 47 cards, and we have 32 cards that make us lose, or 32 to 15, or 2.1333 to 1 (let's just simplify this for easier maths to 2 to 1), in other words we are twice as likely to lose this pot than win it. We need to now work out how much you'd normally win from odds like this. Let's assume a bet of 10$ at 2 to 1 would return a win of 20$ you would normally win. So in order to make a breakeven play we would need to win twice our bet.
Now we have our odds we can work out the pot odds, as you correctly worked out 100 / 40 gives you odds of 2.5 to 1. When we compare 2 to 1 expected money you'd normally win of 20$ to the odds of 2.5 to 1's expected payout of 25$ we can see that these odds now make calling a profitable play in the long run. We are getting better odds than our hand should be getting.
Your odds will be much the same to draw for the river as an individual event. So to make it worth it you need to be getting a better price than 2.1333 to 1.
You can see a pretty good condensed version of the odds based on your outs via this image.

The above only factors in calling a single street, obviously if you factor in calling the entire way to the river, this will change the pot odds. Some nice little tools for this can be found here:
- Online browser calculator
- Downloadable calculator
- Good explanation of calculating odds
As for your second question, why would you be calling when you know you have the best hand, I think in general a better line to take (obviously not always) is the straight forward line and bet to win some money. It's a pretty big broad question to ask with many variables that it's not as straight forward to say I have x, they have y how much do I call. You'd need to let us know some additional information, stack sizes, villain's ability, table dynamics, whois winning, whois stuck and on tilt, etcetera.