Actors who improvise are not making things up as themselves, they are making things up as someone else. To do this, an actor must have developed an intimate knowledge of the character they are playing. This sort of knowledge is very helpful as an actor even when you are working on scripted material, which is why improvisation is often used as a rehearsal exercise. If the director suddenly screams 'Where have you been?' as you step on to the set, they are probably not interested in the cup of herbal tea you brewed in the office while chatting with another actor about your respective agents. They are asking what you think your character has been doing during the time you were offstage. This is a good moment to improvise.
Directors might also want the actors to have improvised conversations in character. If the writer has referred to the time the lovers in the play first met in prison ten years ago, the actors could improvise the scene as a way of making a 'real' memory. There is not usually enough rehearsal time to spend on improvisation; learning what to say in addition to how, where and most importantly when to say it, takes up the larger portion of the commonly allocated three weeks. If your fellow actor's prison antics are not conducive to the happy love affair you imagined, you may be glad that the improvisation exercises had to be squeezed into an afternoon between costume fittings.
Where whole plays or films are constructed from actors improvising scenes, you might think that the actors also receive writing credits/payment. This is not the case. The improvisation is seen as an extension of the actor's normal range of duties. It does not work the other way round. David Hare is paid to perform and if Richard Curtis wanted to serenade Laura Linney under a Fig Tree in his next Romantic Comedy, I'm sure he could command a small fee. However, since actors often develop characters with writers, frequently work on scripts with directors and request line changes all the time, I suspect that this is a Can of Worms.
One of the first plays I was in was directed by an enthusiastic improvisor. That is, he told us to improvise and we did it. The atmosphere was quite intimidating. We were not allowed to bring anything in to the rehearsal room that did not pertain to the play or the time period (1940's). We had a lot of character 'homework' to do and there was plenty of shouting. One day, the director told everyone to leave the room so that I could work on a private improvisation with one of the other actors. It was to be an intimate moment in our affair that would lend some truth to our relationship history. The other actor was not from the improvisation school of acting and was reluctant to take part. I was from a school that only used improvisation and particularly wanted to avoid more shouting. I'm not sure what Terrence Rattigan would have written had he included the scene, but as soon as the director asked us to start my co-star turned to me with a look of fury and said 'Why do you have be such a bitch?'. It went downhill from there.
The play, however, was a hit.