While they might taste great together in a salad, tomato plants actually dislike growing in close proximity to any member of the cucurbit family, which includes cucumbers.
Companion plants assist in the growth of others by attracting beneficial insects, repelling pests, or providing nutrients, shade, or support. They can be part of a biological pest control program.