Dr Barry Morgan is leading a service of thanksgiving at St John the Baptist High School, Aberdare, on Wednesday.
More than 100 clergy are expected as well as past and present staff and students.
The school choir will sing "A Blessing", an anthem composed by Year 10 pupil David Anthony.
Archbishop Morgan and the pupils will also bury a time capsule in the school grounds after the special service, and old photographs and medals will be on display, including those of former pupil and Paralympic athlete Rhys Jones.
The Archbishop paid tribute to the school: "I am delighted to join St John's as it celebrates its 40th birthday.
"It's a remarkable school which values and encourages all its pupils - teaching them not just how to pass exams - although it does that very well - but how to care for others, be compassionate and have faith.
"Over the years it has nurtured several generations of children in strong Christian values and become a key part of the community it serves."
Headteacher Dr Susan Mitchell said: "This celebration is the climax of a very successful year for our school.
"Estyn school inspectors graded the school as 'Excellent' and the Welsh Government has categorised the school as a 'Green' and 'Category 1' school.
"This shows the school has gone from strength to strength, which is a fitting tribute to the oldest Church in Wales secondary school.
"As only the third Head teacher of St John's, it is a privilege for me, the staff and pupils to enjoy such a prestigious occasion."